﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Simhopp.GUI;
using Simhopp.Model;

namespace Simhopp.Presenter
{
    class PresenterEditJudges
    {
        private InterfaceEditJudgesView _view { get; set; }
        private InterfaceCompetitionModel _model { get; set; }
        public List<Judge> CompleteJudgeList { get; set; }
        public PresenterEditJudges(InterfaceEditJudgesView view, 
            InterfaceCompetitionModel model)
        {
            this._view = view;
            this._model = model;
            this._view.EventAddJudge += _view_EventAddJudge;
            this._view.EventRemoveJudge += _view_EventRemoveJudge;
            this._view.EventUpdateJudge += _view_EventUpdateJudge;
            this._view.EventUpdateJudgeList += _view_EventUpdateJudgeList;
            this._view.EventUpdateCompleteJudgeList += _view_EventUpdateCompleteJudgeList;
            this._view.EventAddExistingJudge += _view_EventAddExistingJudge;
        }

        void _view_EventAddExistingJudge(Judge judge)
        {
            this._model.AddExistingJudge(judge);
        }

        void _view_EventUpdateCompleteJudgeList(List<Judge> completeJudgeList)
        {
            this._model.GetCompleteJudgeList(completeJudgeList);
        }

        void _view_EventUpdateJudge(Judge judge)
        {
            this._model.UpdateJudge(judge.ID, judge.Name, judge.Nationality, judge.Password, judge.Username);
        }

        void _view_EventRemoveJudge(Judge judge)
        {
            this._model.RemoveJudge(judge.ID);
        }

        void _view_EventAddJudge(Judge judge)
        {
            this._model.AddJudge(judge);
        }

        List<Judge> _view_EventUpdateJudgeList()
        {
            return this._model.JudgeList;
        }
    }
}
